// import { userInfo } from './../.history/src/api/user/type_20230316091232';
import router from '@/router'
import useUserStore from '@/store/modules/user/user'
// import fetchApi from '@/api/user/user'

// 路由拦截
router.beforeEach(async(to, from, next) => {
  const userStore = useUserStore()
 
  // 路由白名单
  const whiteList:string[] = []
  // 如果在白名单内则直接跳转
  if(whiteList.includes(to.path)){
    next()
  }else{
    console.log('userStore',userStore.userInfo)
    //判断是否有用户信息或者token
    if(userStore.userInfo.id){
      console.log('yuxin')
      next()
    }else{
      // 没有用户信息时，请求接口取用户信息
    const res = await  userStore.getUserInfo()
    if(res){
      next()
    }
    

    }
  }

})